package com.basejace.core.web;

import javax.servlet.http.HttpSession;

import com.basejace.core.R;
import com.basejace.core.model.LoginUserBean;

public class SessionUtils {
	private LoginUserBean loginUser;
	
	private static SessionUtils instance = new SessionUtils();
	public static SessionUtils me() {
		return instance;
	}
	private SessionUtils(){}
	
	public void setLoginUser(HttpSession session, LoginUserBean loginUser) {
		session.setAttribute(R.Key.LOGIN_USER, loginUser);
		this.loginUser = loginUser;
	}
	
	public Long getUserid() {
		return getLoginUser().getUserid();
	}
	
	public LoginUserBean getLoginUser() {
		return this.loginUser;
	}
	
	public LoginUserBean getLoginUser(HttpSession session) {
		this.loginUser = (LoginUserBean)session.getAttribute(R.Key.LOGIN_USER);
		return loginUser;
	}
}
